<%@ page language="java" import="java.util.*,java.sql.*,com.wcll.www.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<jsp:useBean id="pages" class="com.wcll.www.ShowSortBean"></jsp:useBean>
<jsp:setProperty name="pages" property="*"/>
    <select name="jsid" id="jaa" onChange="showjaa(this.value);">
    <option>单击选择</option>
    <%
    	request.setCharacterEncoding("UTF-8");
    	String ss = null;
    	int a=0;
    	if(request.getParameter("opid")!=null){
    	ss = request.getParameter("opid");
    	a = Integer.parseInt(ss);
    	}
		Class.forName("com.mysql.jdbc.Driver");
		Connection con = DriverManager.getConnection("jdbc:mysql://localhost/jobs","root","");
		Statement st = con.createStatement();
		ResultSet rs = st.executeQuery("select * from job_assort order by id desc");
		while(rs.next()){
		if(a==rs.getInt("id")){
		%>
		<option value="<%=rs.getInt("id")%>" selected="selected"><%=rs.getString("ja_name")%></option>
		<% }else{%>
				<option value="<%=rs.getInt("id")%>"><%=rs.getString("ja_name")%></option>
			<% }}%>
			<% 
			rs.close();
			st.close();
			con.close();
		%>
    </select>
 <div style="text-align:center;font-size:12px;">
<% 
	if(request.getAttribute("jaa")!=null){
 	ArrayList<ShowSortBean> al = (ArrayList<ShowSortBean>)request.getAttribute("jaa");
 	Iterator<ShowSortBean> ial = al.iterator();
 	%>
 	<table style="text-align:center;font-size:12px;" border="1">
 		<tr>
 			<td>编号</td>
 			<td>职位</td>
 			<td  colspan="2">基本操作</td>
 			</tr>
 				<% 
 	while(ial.hasNext()){
 	ShowSortBean ab = ial.next();
 	%>
 		<tr>
 			<td><%=ab.getId()%></td>
 			<td><%=ab.getName()%></td>
 			<td><span style="text-decoration:underline;cursor:hand;" onClick="xiugai(<%=ab.getId() %>,'<%=ab.getName()%>');">修改</span></td>
 			<td><span style="text-decoration:underline;cursor:hand;" onClick="dele(<%=ab.getId() %>);">删除</span></td>
 			
 		</tr>
 		
 	<%}	
}%>
</table>
    <div id = "dd" style="display:none;position:absolute;top:200px;left:200px;z-index:10;width:350px;">
	<span style="float:right;cursor:hand;font-size:12px;" onClick="hidden();">[&nbsp;关闭&nbsp;]</span>
	<span id="js"></span>
	<form id="ff" action="" method="POST">
	<input type="hidden" id="jaaid" name="jaaid" />
	<table style="text-align:center;font-size:12px;" border="1">
	<tr>
	<td>名称:</td>
	<td><input type="text" id="jaaname" name="jaaname" /></td>
	</tr>
	<tr>
	<td colspan="2" align="center"><input type="submit" value="确认" onClick="hidden();"/></td>
	</tr>
	</table>
	</form>
</div>
<span style="font-size:12px;float:left;">
<%
	
	int p = pages.getCounts("select count(*) as a  from job_assort_avatar where ja_id="+a);
	for(int i =1;i<=p;i++){
	%>
	<a href="<%=basePath%>servlet/JobSortServlet?id=<%=ss %>&currage=<%=i %>">第<%=i %>页</a>
	<%}
 %>
</span>
</div>
<script>
function xiugai(id,mingcheng){
	var d = document.getElementById("dd");
	var ff = document.getElementById("ff");
	var jaaid = document.getElementById("jaaid");
	var jaaname = document.getElementById("jaaname");
	ff.action = "<%=basePath%>/servlet/ModfiyJSServlet";
	jaaid.value = id;
	jaaname.value = mingcheng;
	d.style.display="block";
}
function hidden(){
	var d = document.getElementById("dd");
	d.style.display="none";
}
function dele(id){
	location = "<%=basePath%>/servlet/ModfiyJSServlet?deleid="+id;
}
function showjaa(id){
	location = "<%=basePath%>/servlet/JobSortServlet?id="+id;
}
</script>
